[IA64][MINIOS] PKR support
authorAlex Williamson <alex.williamson@hp.com>
Tue, 31 Jul 2007 00:14:29 +0000 (18:14 -0600)
committerAlex Williamson <alex.williamson@hp.com>
Tue, 31 Jul 2007 00:14:29 +0000 (18:14 -0600)
- adds optimization feature for region 7 identity mapping
- adds protection keys to region 5 and region 7 addresses,
  may be used for testing the hypervisor protection key support

Signed-off-by: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com>
extras/mini-os/arch/ia64/common.c
extras/mini-os/arch/ia64/ia64.S
extras/mini-os/arch/ia64/ivt.S
extras/mini-os/include/ia64/hypercall-ia64.h
extras/mini-os/include/ia64/ia64_cpu.h
extras/mini-os/include/ia64/page.h

index 13416d954263ce62c29fd14b3fed46dadb107b39..cd4cec1e209d461b4ff5f6f3db190423918c202e 100644 (file)
@@ -103,7 +103,8 @@ map_pal_code(void)
         */
        ia64_ptc_l(machineFwG.ia64_pal_base, PTE_PS_16K);
        ia64_write_itr_i(&pte, IA64_TR_PAL,
-                        (uint64_t) machineFwG.ia64_pal_base, PTE_PS_16K, 0);
+                        (uint64_t)machineFwG.ia64_pal_base,
+                        PTE_PS_16K, IA64_KEY_REG7);
        xen_set_virtual_psr_ic(1);
 }
 
@@ -180,6 +181,21 @@ init_boot_params(void)
                bootverbose = 1;
 }
 
+static void
+set_opt_feature(void)
+{
+       struct xen_ia64_opt_feature optf;
+
+       optf.cmd = XEN_IA64_OPTF_IDENT_MAP_REG7;
+       optf.on = XEN_IA64_OPTF_ON;
+       optf.pgprot = ((1 << PTE_OFF_P) | (1 << PTE_OFF_A) | (1 << PTE_OFF_D) |
+                      (PTE_MA_WB << PTE_OFF_MA) |
+                      (PTE_PL_KERN << PTE_OFF_PL) |
+                      (PTE_AR_RW << PTE_OFF_AR));
+       optf.key = IA64_KEY_REG7;
+       HYPERVISOR_opt_feature(&optf);
+}
+
 void
 arch_init(start_info_t *si)
 {
@@ -213,6 +229,9 @@ arch_init(start_info_t *si)
                printk("efi_get_time() failed\n");
 
        registerCallback();
+
+       set_opt_feature();
+
        initialized = 1;
 }
 
index 4374c750e7f9e82bc99726afe3e66cc4245e78e0..7ea9433199dfaa1b42293ababdc96efc6c908e3a 100644 (file)
@@ -101,11 +101,21 @@ ENTRY(_start)
        ;;
        mov     rr[r3]=r2
        ;;
-
+       /*
+        * Setup protection keys for region 5 and 7.
+        */
+       mov     r2=(IA64_KEY_REG5 << IA64_PKR_KEY) | IA64_PKR_VALID
+       mov     r3=(IA64_KEY_REG7 << IA64_PKR_KEY) | IA64_PKR_VALID
+       mov     r14=0x1
+       ;;
+       mov     pkr[r0]=r2      /* Region 5 */
+       mov     pkr[r14]=r3     /* Region 7 */
+       ;;
        /*
         * Now pin mappings into the TLB for kernel text and data
         */
-       mov     r18=KERNEL_TR_PAGE_SIZE<<IA64_ITIR_PS
+       mov     r18=(KERNEL_TR_PAGE_SIZE<<IA64_ITIR_PS)| \
+                       (IA64_KEY_REG5<<IA64_ITIR_KEY)
        movl    r17=KERNEL_START
        ;;
        mov     cr.itir=r18
index 58ff32559f3472eb2cb5d15fbe1301fd7b16ca2d..79971fef34c63ab1591f7854343ffa41c91361a1 100644 (file)
@@ -249,7 +249,7 @@ ENTRY(save_tf_rse_switch)
                /* xen special handling for possibly lazy cover */
        movl    r8=XSI_PRECOVER_IFS;
        ;;
-       ld8     r21=[r8];
+       ld8     r21=[r8]
        ;;
 #if defined(BIG_ENDIAN)                        // swap because mini-os is in BE
        mux1    r21=r21,@rev
@@ -771,7 +771,7 @@ adt_reg7_addr:
         * addresses. Currently I don't do a check.
         */
        movl    r20=~((7 << IA64_RR_IDX_POS) | 0xfff)
-       movl    r18=((PTE_PS_16K<<IA64_ITIR_PS)|(0<<IA64_ITIR_KEY))
+       movl    r18=((PTE_PS_16K<<IA64_ITIR_PS)|(IA64_KEY_REG7<<IA64_ITIR_KEY))
        ;;
        movl    r19=    ((1<<PTE_OFF_P) | (PTE_MA_WB<<PTE_OFF_MA) | \
                         (1<<PTE_OFF_A) | (1<<PTE_OFF_D) | \
index 2a4415879ded05fa3cf5a0f8a6615ff4306f01b9..bca01b118d8202f23f065446878b757a75a7c874 100644 (file)
@@ -223,4 +223,14 @@ xencomm_arch_hypercall_grant_table_op(unsigned int cmd,
 
 int HYPERVISOR_grant_table_op(unsigned int cmd, void *uop, unsigned int count);
 
+static inline int
+HYPERVISOR_opt_feature(void *arg)
+{
+       struct xencomm_handle *new_arg;
+
+       new_arg = xencomm_create_inline(arg);
+
+       return _hypercall1(int, opt_feature, new_arg);
+}
+
 #endif /* __HYPERCALL_H__ */
index f5bc10b28bafcaaefb27298f9ac8fc6d2bfa0ce8..f9ebf7329f66bf6b8c22f0e2e0df007e3c5f1eca 100644 (file)
 #define MOS_IA64_PSR_BE        0
 #endif
 
-#define STARTUP_PSR (IA64_PSR_IT | \
+#define STARTUP_PSR (IA64_PSR_IT | IA64_PSR_PK | \
                     IA64_PSR_DT | IA64_PSR_RT | MOS_IA64_PSR_BE | \
                     IA64_PSR_BN | IA64_PSR_CPL_KERN | IA64_PSR_AC)
 
index 8f16527148c4046586e5f5fdf6c90ea98b4b8e17..714227f17251e512bed4511172ab36a4cc7a4fee 100644 (file)
@@ -99,6 +99,10 @@ extern paddr_t phys_avail[];
 #define KERN_VIRT_2_PHYS(x) (((x) - KERNEL_START) + \
                                (1 << KERNEL_PHYS_START_SHIFT))
 
+/* Some protection keys for region 5 and 7 addresses. */
+#define IA64_KEY_REG7  0x234   /* Region 7 - identity mapped addresses */
+#define IA64_KEY_REG5  0x89a   /* Region 5 - kernel addresses */
+
 // This is xen specific !
 #define PAGE_SHIFT_XEN_16K     14      // For 16KB page size
 #define mfn_to_virt(mfn)       ((void*)__va((mfn) << PAGE_SHIFT_XEN_16K))